package com.szpt.mo.bhubackground.util.config.JWTInterceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private JWTInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        ArrayList<String> exclude = new ArrayList<>();
        exclude.add("/user/login");
        exclude.add("/verifyCode/**");

        exclude.add("/code");

        exclude.add("/file/**");


        exclude.add("/swagger-ui.html");
        exclude.add("/webjars/**");
        exclude.add("/v2/**");
        exclude.add("/swagger-resources/**");
        exclude.add("/doc.html");

        registry.addInterceptor(jwtInterceptor)
                //其他接口需要token验证，拦截器拦截
                .addPathPatterns("/hello/h1")
                .addPathPatterns("/**")

                .excludePathPatterns(exclude);
    }
}
